<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition>
	<h:panelGrid columns="1" style="width:100%">
		<h:panelGrid columns="2" style="width:100%">
			<p:commandButton ajax="true" update="productListTable,:detailForm"
				actionListener="#{productController.initWithoutCheck}"
				value="Reload" style=" font-size:0.9em;float:left"></p:commandButton>
			<h:commandLink value="Print"
				style="color:green;font-weight:bold;float:right">
				<p:fileDownload value="#{productController.filteredProductListPdf}"></p:fileDownload>
			</h:commandLink>
		</h:panelGrid>
	</h:panelGrid>
	<p:dataTable id="productListTable" var="product"
		value="#{productModel.list}"
		filteredValue="#{productModel.filteredList}" filterEvent="enter"
		resizableColumns="false" rowKey="#{product.id}"
		selection="#{productModel.current}" selectionMode="single"
		paginator="true" paginatorAlwaysVisible="false"
		paginatorPosition="top" rows="10"
		rowsPerPageTemplate="5,7,10,15,20,30,40,50"
		paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
		<p:ajax event="rowSelect" update=":detailForm,:headerForm"
			listener="#{productController.onRowSelect}"></p:ajax>

		<p:column headerText="id" sortBy="#{product.id}">
			<h:outputText value="#{product.id}" />
		</p:column>
		<p:column sortBy="#{product.number}">
			<h:outputText value="#{product.number}" />
		</p:column>
		<p:column sortBy="#{product.chineseName}"
			filterBy="#{product.chineseName}" filterMatchMode="contains">
			<h:graphicImage library="images" value="../#{product.icon}16.png"></h:graphicImage>
			<h:outputText value="#{product.chineseName}" />
		</p:column>
		<p:column sortBy="#{product.name}" filterBy="#{product.name}"
			filterMatchMode="contains">
			<h:outputText value="#{product.name}" />
		</p:column>
		<p:column headerText="Price" sortBy="#{product.price}">
			<h:outputText value="#{product.price}" />
		</p:column>
		<p:column headerText="Sp. Price" sortBy="#{product.specialPrice}">
			<h:outputText value="#{product.specialPrice}" />
		</p:column>
		<p:column headerText="Unit Price" sortBy="#{product.unitPrice}">
			<h:outputText value="#{product.unitPrice}" />
		</p:column>
		<p:column headerText="inventory" sortBy="#{product.inventory}">
			<h:outputText value="#{product.inventory}" />
		</p:column>
		<p:column headerText="Best Before" sortBy="#{product.bestBefore}"
			filterBy="#{product.bestBefore}" filterMatchMode="contains">
			<h:outputText value="#{product.bestBefore}" />
		</p:column>
		<p:column sortBy="#{product.type.label}"
			filterBy="#{product.type.label}" filterMatchMode="contains">
			<h:outputText value="#{product.type.label}" />
		</p:column>
		<p:column sortBy="#{product.supplier.name}"
			filterBy="#{product.supplier.name}" filterMatchMode="contains">
			<h:outputText value="#{product.supplier.name}" />
		</p:column>
	</p:dataTable>
</ui:composition>
</html>